package com.zan.controller;

import com.zan.service.CategoryService;
import com.zan.service.IndexImgService;
import com.zan.service.ProductService;
import com.zan.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/index")
@Api(value = "提供首页数据显示所需的相关接口", tags = "首页管理")
public class IndexController {

    @Autowired
    private IndexImgService indexImgService;

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private ProductService productService;

    @GetMapping("/img")
    @ApiOperation("首页轮播图接口")
    public ResultVo listIndexImgs() {
        return indexImgService.listIndexImg();
    }

    @GetMapping("/category-list")
    @ApiOperation("商品分类查询接口")
    public ResultVo listCategories() {
        return categoryService.listAllCategories();
    }

    @GetMapping("/list-recommends")
    @ApiOperation("查询新品推荐商品接口")
    public ResultVo listRecommendProducts() {
        return productService.listRecommendProducts();
    }

    @GetMapping("/category-recommends")
    @ApiOperation("分类推荐接口")
    public ResultVo listFirstLevelCategories() {
        return categoryService.listFirstLevelCategories();
    }
}
